package PCLockRefine;

import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.Lock;

public class PrintLetterThread extends Thread {
    private Lock lock;
    private Condition condition;

    public PrintLetterThread(Lock lock, Condition condition) {
        this.lock = lock;
        this.condition = condition;
    }

    @Override
    public void run() {
        lock.lock();
        for (int i = 0; i < 26; i++) {
            try {
                condition.await();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.print((char) ('A' + i) + " ");
            condition.signal();
        }
        lock.unlock();
    }
}
